$(function(){
	var state,carouselNum=4,topNum=10,path="";
	//加载精选新闻
	var params = {"carouselNum":carouselNum};
	/*$.post("/csg_pic/path/newsinfo/news-carousel-json", params,
			function(result) {
				if (result.state == 'Success') {
					var tag = $('#carousel-news');
					for(var i = 0 ; i < result.content.length; i++){
						var data = result.content[i];
						//alert(data.cover_path+"-"+data.title);
						var li = "";
						li += "<li id=\"id1\">";
						li += "<a href=\"#\">";
						li += "<img src=\"/csg_pic"+data.cover_path+"\" alt=\"\" />";
						li += "</a>";
						li += " <h3><a href=\"#\">"+data.title+"</a></h3>";
						li += " <p>45分钟前</p>";
						li += "</li>";
						tag.html(li);
					}
				} else {
					alert("操作失败,原因："+result.content);
				}
			}
		);*/
	//加载头条新闻
	/*$.post("/csg_pic/path/newsinfo/news-top-json", {"topNum":topNum},
			function(result) {
				if (result.state == 'Success') {
					
					var tag = $('#top-news');
					var html = tag.html();
					for(var i = 0 ; i < result.content.length; i++){
						var data = result.content[i];
						//alert(data.cover_path+"-"+data.title);
						html += "<dd><div class=\"topNews-timer fn-pr\"><em class=\"timer-day\">"+data.day_+"</em><em class=\"timer-line\">/</em>";
						html += "<em class=\"timer-month\">"+data.month_+"月</em></div><div class=\"topNews-tps\"><a href=\"#\" target=\"_blank\">";  
						html += "<h3 class=\"fn-wto\">"+data.title+"</h3><p>"+data.content+"</p> </a></div></dd>";  
						tag.html(html);
					}
				} else {
					alert("操作失败,原因："+result.content);
				}
			}
		);*/
	//加载主题
	
	//加载新闻展示
	/*$.post("/csg_pic/path/newsinfo/columns-news-json", {"rows":10,"columnId":"5bf25fe0155bf25fe9f0000"},
			function(result) {
				if (result.state == 'Success') {
					
					var tag = $('#column-news');
					var html = tag.html();
					for(var i = 0 ; i < result.content.length; i++){
						var data = result.content[i];
						//alert(data.cover_path+"-"+data.title);
						html += "<li data-key=\"t\"><div class=\"mod-ListImg-pic\">";
						html += "<a href=\"#\" title=\""+data.title+"\"><img src=\"/csg_pic/"+data.cover_path+"\" alt=\""+data.title+"\" /></a>";
						html += "</div><div class=\"mod-ListImg-hd\"><h3 title=\"title\"><a href=\"#\" title=\""+data.title+"\">"+(i+1)+data.title+"</a> </h3><div class=\"mod-ListImg-orgin\">编辑<em>：</em>"+data.editor+"<em>/</em>摄影<em>：</em>"+data.photographer+"</div> </div><div class=\"mod-ListImg-info\"><p class=\"mod-ListImg-dersc\">"+data.nabstract+"</p>";
						html += "<p class=\"mod-ListImg-tips clearfix\"><span class=\"fn-fl\"><i class=\"glyphicon glyphicon-eye-open\"></i>2452</span>";
						html += "<span class=\"fn-fr\">"+data.publish_time+"</span></p></div></li> ";
						tag.html(html);
					}
				} else {
					alert("操作失败,原因："+result.content);
				}
			}
		);*/
	//最新专题
	//点击排行榜
	$.post("/csg_pic/path/newsinfo/news-upUpdate-json", {"rows":10},
			function(result) {
				if (result.state == 'Success') {
					var tag = $('#update-tops');
					var html = "";
					for(var i = 0 ; i < result.content.length; i++){
						var data = result.content[i];
						var style = "";
						if(i < 3){style = " class=\"mod-numList\"";}
						html += "<li "+style+"><a href=\"/csg_pic/path/newsinfo/frontNewsInfo?newsId="+data.id+"\" title=\"\" class=\"mod-textList-item clearfix\"  target=\"_blank\"><i class=\"fn-fl\">"+(i+1)+"</i><span class=\"mod-textList-info fn-wto\">"+data.title+"</span></a></li>";
						tag.html(html);
					}
				} else {
					alert("操作失败,原因："+result.content);
				}
			}
		);
	
      //图片异常处理
	  var imgTags = document.getElementsByTagName("img");
	  for(var i = 0; i < imgTags.length; i++){
		  imgTags.item(i).onerror = function(){
	            this.src = "/csg_pic/zenithsun/news/mobile/images/Default-bg270x180.png";
	            this.onerror = null;
	      };
	  }
}); 